package com.eaoa.uc.account.bo;

import org.apache.commons.lang.StringUtils;

import com.eaoa.base.EABaseBusinessObject;
import com.eaoa.constants.PubConstantsType;
import com.eaoa.dao.pub.PubAccountDAO;
import com.eaoa.utils.ConstantsContainer;
import com.eaoa.vo.pub.PubAccount;
import com.stony.core.util.CoreUtils;
import com.stony.core.util.MD5;

public class LoginPasswordResetBO extends EABaseBusinessObject {

	private PubAccount vo;

	private PubAccountDAO employeeDAO = new PubAccountDAO();

	public LoginPasswordResetBO(PubAccount vo) {
		super();
		this.vo = vo;
	}

	protected void performBusinessLogic() {

		PubAccount po = (PubAccount) employeeDAO.loadAndLock(vo.getAccountno());

		if (StringUtils.isNotBlank(vo.getName()))
			po.setName(vo.getName());

		MD5 m = new MD5();

		if (StringUtils.isNotBlank(vo.getPassword()))
			po.setPassword(m.getMD5ofStr(CoreUtils.formatString(vo
					.getPassword())));

		po.setEmail(vo.getEmail());

		po.setMobilephone(vo.getMobilephone());

		po.setTelephone(vo.getTelephone());
		
		po.setIsfirstlogon("N");

		employeeDAO.update(po);

		ConstantsContainer.getInstants().setVO(PubConstantsType.Employee, po);

	}

}